import React, { Component } from 'react'
import {Switch,Route,Redirect} from 'react-router-dom'
import MyNavLink from '../../components/MyNavLink'
import News from './News'
import Message from './Messages'

export default class Home extends Component {
  render() {
    // console.log('路由组件接收的参数',this.props)
    return (
      <div>
        <h3>我是home组件</h3>
        {/* 
          嵌套路由 有关的路由组件给的地址一定要是给完整的地址
            另外注意 嵌套路由就一定要注意 exatc 精准匹配要关闭 否则匹配补上就会走到最外层路由的重定向上面了

            路由一定是先从最外层的路由进行匹配的
        */}
        <MyNavLink to="/home/news">News</MyNavLink>
        <MyNavLink to="/home/message">Message</MyNavLink>

        <Switch>
          <Route path="/home/news" component={News} />
          <Route path="/home/message" component={Message} />
          <Redirect to="/home/news" />
        </Switch>
      </div>
    )
  }
}
